|
RAIS
3.2
|
00001 00028 using System; 00029 using System.Collections.Generic; 00030 using System.Data; 00031 using System.Text; 00032 00033 using RAIS.Common.TableManagement; 00034 //using RecordTypes = System.Collections.Generic.Dictionary<RAIS.Common.DynamicMaskManagement.ConsistencyCheck.RecordType, RAIS.Common.DynamicMaskManagement.ConsistencyCheck.RecordTypeData>; 00035 using RecordTypes = System.Collections.Generic.Dictionary<string, RAIS.Common.DynamicMaskManagement.ConsistencyCheck.RecordTypeData>; 00036 00037 namespace RAIS.Common.DynamicMaskManagement 00038 { 00039 public class ConsistencyCheck: DBObject 00040 { 00041 //********************************************************************* 00042 #region Enums 00043 public enum RecordType 00044 { 00045 AllRecords = 0, 00046 NewRecords, 00047 OldRecords 00048 } 00049 #endregion 00050 //********************************************************************* 00051 #region Fields 00052 static RecordTypes recordTypesDictionary; 00053 00054 string queryName; 00055 string message; 00056 RecordType type = RecordType.AllRecords; 00057 #endregion 00058 //********************************************************************* 00059 #region Properties 00060 00063 static public RecordTypes RecordTypesDictionary 00064 { 00065 get { return recordTypesDictionary; } 00066 set { recordTypesDictionary = value; } 00067 } 00068 00072 new public string Name 00073 { 00074 get { return this.name; } 00075 } 00079 public string QueryName 00080 { 00081 get { return this.queryName; } 00082 set 00083 { 00084 this.queryName = value; 00085 this.name = GetNameFromQueryName(); 00086 } 00087 } 00091 public string Message 00092 { 00093 get { return message; } 00094 set { message = value; } 00095 } 00099 public RecordType Type 00100 { 00101 get { return this.type; } 00102 set { this.type = value; } 00103 } 00107 public RecordTypeData TypeData 00108 { 00109 get { return RecordTypesDictionary[this.TypeText]; } 00110 } 00111 00112 public string TypeText 00113 { 00114 get 00115 { 00116 string result = string.Empty; 00117 foreach (KeyValuePair<string, RecordTypeData> recordTypeItem in recordTypesDictionary) 00118 if (recordTypeItem.Value.Type == this.type) 00119 { 00120 result = recordTypeItem.Value.VisibleName; 00121 break; 00122 } 00123 return result; 00124 } 00125 set 00126 { 00127 this.type = recordTypesDictionary[value].Type; 00128 } 00129 } 00130 #endregion 00131 //********************************************************************* 00132 #region Constructors 00133 public ConsistencyCheck() 00134 { } 00135 public ConsistencyCheck(IDataRecord record) 00136 { 00137 this.id = (int)record["PK Consistency Check ID"]; 00138 this.queryName = record["Query Name"].ToString(); 00139 this.message = record["Message"].ToString(); 00140 this.type = (RecordType)Enum.Parse(typeof(RecordType), record["Record Type Name"].ToString()); 00141 00142 this.name = GetNameFromQueryName(); 00143 } 00144 #endregion 00145 //********************************************************************* 00146 #region Public methods 00147 //public void SetQueryNameFromQuery(Query query) 00148 //{ 00149 // if (query != null) 00150 // { 00151 // StringBuilder queryName = new StringBuilder(query.Name); 00152 00153 // if (query.QueryParameters != null && query.QueryParameters.Count != 0) 00154 // { 00155 // queryName.Append("("); 00156 00157 // bool firstParameter = true; 00158 // foreach (KeyValuePair<string, QueryParameter> kvp in query.QueryParameters) 00159 // { 00160 // QueryParameter queryParameter = kvp.Value; 00161 00162 // if (!firstParameter) 00163 // queryName.Append(", "); 00164 00165 // queryName.Append(queryParameter.VisibleName); 00166 // firstParameter = false; 00167 // } 00168 00169 // queryName.Append(")"); 00170 // } 00171 00172 // this.queryName = queryName.ToString(); 00173 // this.name = GetNameFromQueryName(); 00174 // } 00175 //} 00176 #endregion 00177 //********************************************************************* 00178 #region Private methods 00179 string GetNameFromQueryName() 00180 { 00181 int breacketIndex = this.queryName.IndexOf('('); 00182 00183 if (breacketIndex == -1) 00184 return this.queryName; 00185 else 00186 return this.queryName.Substring(0, breacketIndex); 00187 } 00188 #endregion 00189 //********************************************************************* 00190 #region Nested Classes 00191 public class RecordTypeData : DBTypeObject 00192 { 00193 //********************************************************************* 00194 #region Properties 00195 00196 00197 00198 public RecordType Type 00199 { 00200 get { return (RecordType)Enum.Parse(typeof(RecordType), this.name); } 00201 } 00202 #endregion 00203 //********************************************************************* 00204 #region Constructors 00205 public RecordTypeData() 00206 { } 00207 public RecordTypeData(IDataRecord record) 00208 { 00209 this.id = (int)record["PK Record Type ID"]; 00210 this.name = record["Record Type Name"].ToString(); 00211 this.visibleName = record["Record Type Visible Name"].ToString(); 00212 } 00213 #endregion 00214 } 00215 #endregion 00216 } 00217 }